<?php
    if(isset($_POST['setSent'])){
        setSentNo($_POST['depart_id'],$_POST['sent_no'],$_POST['doctypesent']);
    }
?>

	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
	<tr valign="top">
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td><hr align="left" color="#89a00f" width="100%" /></td>
	</tr>
	</tbody>
	</table>
<span class="topic">กำหนดเลขที่ส่งหนังสือ</span>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
	<tr valign="top">
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td><hr align="left" color="#89a00f" width="100%" /></td>
	</tr>
	</tbody>
	</table><br />
	
<table cellpadding="5" cellspacing="0" border="0" width="100%">
<tr><td>
<form action="update.php" method="post" id="sent_form">
<input type="hidden" name="domain" value="sent">
<input type="hidden" name="com" value="depart_ch">

<table cellpadding="5" cellspacing="0" border="0">
<tr><td>หน่วยงาน</td><td>:</td><td>
<?php 
	if(isset($_POST['setSent']) || ($_POST['com']=="depart_ch") || ($_POST['com']=="doctype_ch")){
	    list_department_user($_POST['depart_id'],"sent_form");
	    $depart_id = $_POST['depart_id'];
	}else{
	    list_department_user(0,"sent_form");
	    $depart_id = $_SESSION['edoc_depart_id'];
	}
?>
</td></tr>
</table>
</form>

<form action="update.php" method="post" id="sent_form2">
<input type="hidden" name="domain" value="sent">
<input type="hidden" name="com" value="doctype_ch">
<input type="hidden" name="depart_id" value="<?php echo $depart_id; ?>">

<table cellpadding="5" cellspacing="0" border="0">
<tr><td>ประเภทหนังสือส่ง</td><td>:</td><td>
<?php 
	if($_POST['com']=="doctype_ch"){
		list_doctypesent_option_no_add_for_set($depart_id,$_POST['doctypesent'],"sent_form2"); 
		$doctypesent = $_POST['doctypesent'];
	}else{
		list_doctypesent_option_no_add_for_set($depart_id,0,"sent_form2"); 
		$doctypesent = 0;
	}		
?>
</td></tr>
</table>
</form>

<form action="update.php" method="post" >
<input type="hidden" name="domain" value="sent">
<input type="hidden" name="depart_id" value="<?php echo $depart_id; ?>">
<input type="hidden" name="doctypesent" value="<?php echo $doctypesent; ?>">
<table cellpadding="5" cellspacing="0" border="0" >
<tr><td>เลขที่รับถัดไป</td><td>:</td><td class="topic"><?php echo getSentNo($doctypesent); ?></td></tr>
<tr><td>กำหนดเลขรับถัดไป</td><td>:</td><td><input type="text" name="sent_no" size="20" maxlength="100"></td></tr>
<tr><td colspan="2"> </td><td><input type="submit" name="setSent" value=" กำหนด "></td></tr>

</table>
</form>
